package com.sojson.service.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sojson.dao.RoleMenuDao;
import com.sojson.entity.po.RoleMenu;
import com.sojson.service.RoleMenuService;

/**
 * 角色和菜单关联表Service实现类
 * 
 * @author liu
 * @date 2021-04-13
 */
@Service
public class RoleMenuServiceImpl implements RoleMenuService {

    @Resource
    private RoleMenuDao roleMenuDaoImpl;

    /**
     * 单条插入
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(RoleMenu roleMenu) throws SQLException {
        int insert = roleMenuDaoImpl.insert(roleMenu);
        return insert;
    }

    /**
     * 批量插入
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(RoleMenu roleMenu) throws SQLException {
        int insertList = roleMenuDaoImpl.insertList(roleMenu.getRoleMenus());
        return insertList;
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(RoleMenu roleMenu) throws SQLException {
        int deleteByDto = roleMenuDaoImpl.deleteByDto(roleMenu);
        return deleteByDto;
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() throws SQLException {
        int countAll = roleMenuDaoImpl.countAll();
        return countAll;
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<RoleMenu> findAll() throws SQLException {
        List<RoleMenu> findAll = roleMenuDaoImpl.listAll();
        return findAll;
    }

    /**
     * 根据对象统计数量
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(RoleMenu roleMenu) throws SQLException {
        int countByDto = roleMenuDaoImpl.countByDto(roleMenu);
        return countByDto;
    }

    /**
     * 根据对象查询
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public List<RoleMenu> findByDto(RoleMenu roleMenu) throws SQLException {
        List<RoleMenu> findByDto = roleMenuDaoImpl.listByDto(roleMenu);
        return findByDto;
    }

    /**
     * 通过menuId删除(物理删除)
     * 
     * @param menuId
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByMenuId(Integer menuId) throws SQLException {
        int deleteByMenuId = roleMenuDaoImpl.deleteByMenuId(menuId);
        return deleteByMenuId;
    }

    /**
     * 通过menuId列表删除(物理删除)
     * 
     * @param menuIds
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByMenuIdList(ArrayList<Integer> menuIds) throws SQLException {
        int deleteByMenuIdList = roleMenuDaoImpl.deleteByMenuIdList(menuIds);
        return deleteByMenuIdList;
    }

    /**
     * 通过menuId更新(全部更新)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int updateByMenuId(RoleMenu roleMenu) throws SQLException {
        int updateByMenuId = roleMenuDaoImpl.updateByMenuId(roleMenu);
        return updateByMenuId;
    }

    /**
     * 通过menuId列表更新(全部更新)(更新内容相同)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByMenuIdList(RoleMenu roleMenu) throws SQLException {
        int updateStaticByMenuIdList = roleMenuDaoImpl.updateStaticByMenuIdList(roleMenu);
        return updateStaticByMenuIdList;
    }

    /**
     * 通过menuId列表更新(全部更新)(更新内容不相同)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByMenuIdList(RoleMenu roleMenu) throws SQLException {
        int updateChangeByMenuIdList = roleMenuDaoImpl.updateChangeByMenuIdList(roleMenu.getRoleMenus());
        return updateChangeByMenuIdList;
    }

    /**
     * 通过menuId更新(局部更新)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialByMenuId(RoleMenu roleMenu) throws SQLException {
        int updatePartialByMenuId = roleMenuDaoImpl.updatePartialByMenuId(roleMenu);
        return updatePartialByMenuId;
    }

    /**
     * 通过menuId列表更新(局部更新)(更新内容相同)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByMenuIdList(RoleMenu roleMenu) throws SQLException {
        int updateStaticPartialByMenuIdList = roleMenuDaoImpl.updateStaticPartialByMenuIdList(roleMenu);
        return updateStaticPartialByMenuIdList;
    }

    /**
     * 通过menuId列表更新(局部更新)(更新内容不相同)
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByMenuIdList(RoleMenu roleMenu) throws SQLException {
        int updateChangePartialByMenuIdList = roleMenuDaoImpl.updateChangePartialByMenuIdList(roleMenu.getRoleMenus());
        return updateChangePartialByMenuIdList;
    }

    /**
     * 通过menuId查询
     * 
     * @param menuId
     * @return
     * @throws SQLException
     */
    @Override
    public RoleMenu findByMenuId(Integer menuId) throws SQLException {
        RoleMenu findByMenuId = roleMenuDaoImpl.findByMenuId(menuId);
        return findByMenuId;
    }

    /**
     * 通过menuId列表查询
     * 
     * @param menuIds
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<RoleMenu> findByMenuIdList(ArrayList<Integer> menuIds) throws SQLException {
        ArrayList<RoleMenu> findByMenuIdList = roleMenuDaoImpl.findByMenuIdList(menuIds);
        return findByMenuIdList;
    }

    /**
     * 通过对象查询menuId列表
     * 
     * @param roleMenu
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Integer> findMenuIdByDto(RoleMenu roleMenu) throws SQLException {
        ArrayList<Integer> findMenuIdByDto = roleMenuDaoImpl.findMenuIdByDto(roleMenu);
        return findMenuIdByDto;
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() throws SQLException {
        roleMenuDaoImpl.clear();
    }

}